package com.mazaiting.instructions.extended;

import com.mazaiting.instructions.base.BranchInstruction;
import com.mazaiting.instructions.base.BytecodeReader;
import com.mazaiting.instructions.base.Instruction;
import com.mazaiting.rtda.MtFrame;

/**
 * goto_w指令和goto指令的唯一区别就是索引从2字节变成了4字节
 *
 * @author mazaiting
 * @since 2021/8/15
 */
public class GotoWInstruction {

    public static class GotoW extends BranchInstruction {
        /**
         * 偏移量
         */
        private int offset;

        @Override
        public void fetchOperands(BytecodeReader reader) {
            this.offset = reader.readU4();
        }

        @Override
        public void execute(MtFrame frame) {
            branch(frame, offset);
        }
    }

}
